<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>Apache 的 mpm 工作模式 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>Apache 的 mpm 工作模式</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Apache/">Apache</a> <a class="article__tag-link" href="/tags/LAMP/">LAMP</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;查看 apache 工作模式的命令是：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div></pre></td><td class="code"><pre><div class="line">[root@lamp ~]<span class="comment"># /usr/local/apache2/bin/apachectl -l</span></div><div class="line">Compiled <span class="keyword">in</span> modules:</div><div class="line"> core.c</div><div class="line"> mod_authn_file.c</div><div class="line"> mod_authn_default.c</div><div class="line"> mod_authz_host.c</div><div class="line"> mod_authz_groupfile.c</div><div class="line"> mod_authz_user.c</div><div class="line"> mod_authz_default.c</div><div class="line"> mod_auth_basic.c</div><div class="line"> mod_include.c</div><div class="line"> mod_filter.c</div><div class="line"> mod_log_config.c</div><div class="line"> mod_env.c</div><div class="line"> mod_setenvif.c</div><div class="line"> mod_version.c</div><div class="line"> prefork.c</div><div class="line"> http_core.c</div><div class="line"> mod_mime.c</div><div class="line"> mod_status.c</div><div class="line"> mod_autoindex.c</div><div class="line"> mod_asis.c</div><div class="line"> mod_cgi.c</div><div class="line"> mod_negotiation.c</div><div class="line"> mod_dir.c</div><div class="line"> mod_actions.c</div><div class="line"> mod_userdir.c</div><div class="line"> mod_alias.c</div><div class="line"> mod_so.c</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;apache 三种工作模式：prefork 、 worker 、 event 。可以看到apache 个工作模式是 prefork.c 。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;查看 apache 工作模块的命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div></pre></td><td class="code"><pre><div class="line">[root@lamp ~]<span class="comment"># /usr/local/apache2/bin/apachectl -M</span></div><div class="line">Loaded Modules:</div><div class="line"> core_module (static)</div><div class="line"> authn_file_module (static)</div><div class="line"> authn_default_module (static)</div><div class="line"> authz_host_module (static)</div><div class="line"> authz_groupfile_module (static)</div><div class="line"> authz_user_module (static)</div><div class="line"> authz_default_module (static)</div><div class="line"> auth_basic_module (static)</div><div class="line"> include_module (static)</div><div class="line"> filter_module (static)</div><div class="line"> log_config_module (static)</div><div class="line"> env_module (static)</div><div class="line"> setenvif_module (static)</div><div class="line"> version_module (static)</div><div class="line"> mpm_prefork_module (static)</div><div class="line"> http_module (static)</div><div class="line"> mime_module (static)</div><div class="line"> status_module (static)</div><div class="line"> autoindex_module (static)</div><div class="line"> asis_module (static)</div><div class="line"> cgi_module (static)</div><div class="line"> negotiation_module (static)</div><div class="line"> dir_module (static)</div><div class="line"> actions_module (static)</div><div class="line"> userdir_module (static)</div><div class="line"> alias_module (static)</div><div class="line"> so_module (static)</div><div class="line"> deflate_module (shared)</div><div class="line"> expires_module (shared)</div><div class="line"> rewrite_module (shared)</div><div class="line"> php5_module (shared)</div><div class="line">Syntax OK</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;通过这个命令也可以看到哪些模块是动态，哪些是静态。其中以 mpm_ 开头的就是apache 的 mpm 工作模式，2.2版本的 httpd 默认的 mpm 工作模式为 prefork 。2.4版本的 httpd 默认是 event 工作模式。</p>

	

	
		<span class="different-posts"><a href="/2017/10/12/Apache/8. Apache 的 mpm 工作模式/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
